-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix msd extraneus bytes on reading #2245
Fix msd extraneus bytes on reading #2245
Conversation
I guess that the following place is good to wait for the HW pipe FIFO to be empty. At the last packet of an IN transaction, it will wait for the HW pipe to be empty.
For efficient handling double buffer, I had designed Any way, if we need to wait for HW pipe FIFO to be empty, I suggest the above place, to keep MSC driver API interface. |
This fixes a problem found on MSD class where data read from from disks were sometimes partially overwritten by the status MSD message ("USBS..."). The function introduced wait for the hw fifo pipe to be empty, that prevent that new writing in the fife overwrite data which are not yet be transmitted by hw.
e9def0a
to
7ce4cfa
Compare
I made the changes you suggested and tested them on our device. Now the wait function is static in the RA file dcd_rusb2.c and used in the point you mentioned in the comment. The MSD result untouched in this way and all the changes are only for renesas. In case you prefer some changes to this to better fit the overall architecture please let me know and I will test them on our device. Thanks. |
Thank you for changing and testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @Rbb666, I just pull out my ram41 to test with, this PR indeed causes hanged (block wait) with msc_cdc example. This should be reverted, since the solution does not work as expected and seems to cause more serious issue. |
Yes, this is a problem I detected on Renesas ra8d1. I hope it can be fixed as soon as possible. |
already reverted by #2587 |
Fix the fact that MSD status msg sometimes goes in the payload of data read from disk
This fixes: arduino/ArduinoCore-renesas#84
The problem: when issuing a reading command on MSD class, sometimes data read form disk (QSPI flash device) are corrupted with status message (the one that should "end" the transmission of data read from disk, i.e. "USBS..."). According to our analysis this is due to the fact that given that MSC_STAGE_STATUS case is executed always "after" the state machine implemented in
mscd_xfer_cb
function, if data are still present in the hw pipe fifo while the status message is sent by the function, the status message overwrites part of the data present in the hw pipe fifo.The solution: a function that checks the status of the hw pipe fifo has been implemented. This is a weak function implemented only on RA hw. This function waits until the hw pipe fifo is empty. The function is then called in
mscd_xfer_cb
function when the status message is about to be sent while a reading from disk is finishing. This ensure that data in hw pipe fifo are not overwritten due to lack of sync.If you have a better solution or a more general approach, please feel free to provide us with your implementation, we will test this on our device. Thanks!
@facchinm